home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 August / macformat-027.iso / mac / Shareware City / Developers / Oberon⁄F / Manuals / Language Ref (.txt) < prev    next >
Encoding:
Oberon Document  |  1994-12-19  |  57.6 KB  |  715 lines  |  [oODC/obnF]

  1. Documents.StdDocumentDesc
  2. Documents.DocumentDesc
  3. Containers.ViewDesc
  4. Views.ViewDesc
  5. Stores.StoreDesc
  6. Documents.ModelDesc
  7. Containers.ModelDesc
  8. Models.ModelDesc
  9. Stores.ElemDesc
  10. TextViews.StdViewDesc
  11. TextViews.ViewDesc
  12. TextModels.StdModelDesc
  13. TextModels.ModelDesc
  14. TextModels.AttributesDesc
  15. Geneva
  16. TextRulers.StdRulerDesc
  17. TextRulers.RulerDesc
  18. TextRulers.StdStyleDesc
  19. TextRulers.StyleDesc
  20. TextRulers.AttributesDesc
  21. Geneva
  22. Geneva
  23. Geneva
  24. Geneva
  25. Geneva
  26. Introduction
  27. Oberon/L is Oberon microsystem's implementation of the Oberon-2 language. Oberon microsystems thanks the above mentioned authors, for their friendly permission to use the Oberon-2 report as basis for this document.
  28. The Oberon/L language report differs from Standard Oberon-2 in the following points:
  29. - A type-bound function which returns a pointer may be redefined, such that it returns an
  30. extended type
  31. - Latin-1 character set, which is a superset of Ascii and a subset of Unicode
  32. - Clarified semantics of DIV
  33. - Ranges for the basic types are defined
  34. Relevant changes in the report are marked by underlining the new or changed text parts.
  35. Oberon/L is a general-purpose language in the tradition of Oberon and Modula-2. Its most important features are block structure, modularity, separate compilation, static typing with strong type checking (also across module boundaries), and type extension with type-bound procedures.
  36.     Type extension makes Oberon/L an object-oriented language. An object is a variable of an abstract data type consisting of private data (its state) and procedures that operate on this data. Abstract data types are declared as extensible records. Oberon/L covers most terms of object-oriented languages by the established vocabulary of imperative languages in order to minimize the number of notions for similar concepts.
  37.     This report is not intended as a programmer's tutorial. It is intentionally kept concise. Its function is to serve as a reference for programmers. What remains unsaid is mostly left so intentionally, either because it can be derived from stated rules of the language, or because it would require to commit the definition when a general commitment appears as unwise.
  38.     Appendix A defines some terms that are used to express the type checking rules of Oberon/L. Where they appear in the text, they are written in italics to indicate their special meaning (e.g. the same type).
  39. 2. Syntax
  40. An extended Backus-Naur formalism (EBNF) is used to describe the syntax of Oberon/L: Alternatives are separated by |. Brackets [ and ] denote optionality of the enclosed expression, and braces { and } denote its repetition (possibly 0 times). Non-terminal symbols start with an upper-case letter (e.g. Statement). Terminal symbols either start with a lower-case letter (e.g. ident), or are written all in upper-case letters (e.g. BEGIN), or are denoted by strings (e.g. ":=").
  41. 3. Vocabulary and Representation
  42. The representation of (terminal) symbols in terms of characters is defined using the ASCII set. String
  43. literals,
  44. character
  45. constants,
  46. comments
  47. contain
  48. characters
  49. 8859-1,
  50. Latin-1
  51. extension
  52. ASCII
  53. character
  54. set. Symbols are identifiers, numbers, strings, operators, and delimiters. The following lexical rules must be observed: Blanks and line breaks must not occur within symbols (except in comments, and blanks in strings). They are ignored unless they are essential to separate two consecutive symbols. Capital and lower-case letters are considered as distinct.
  55. 1. Identifiers are sequences of letters and digits. The first character must be a letter.
  56. ident = letter {letter | digit}.
  57. Examples:     x     Scan     Oberon2     GetSymbol     firstLetter
  58. 2. Numbers are (unsigned) integer or real constants. The type of an integer constant is the minimal type to which the constant value belongs (see 6.1). If the constant is specified with the suffix H, the representation is hexadecimal otherwise the representation is decimal.
  59.     A real number always contains a decimal point. Optionally it may also contain a decimal scale factor. The letter E (or D) means "times ten to the power of". A real number is of type REAL, unless it has a scale factor containing the letter D. In this case it is of type LONGREAL.
  60. number     = integer | real.
  61. integer     = digit {digit} | digit {hexDigit} "H".
  62. real     = digit {digit} "." {digit} [ScaleFactor].
  63. ScaleFactor     = ("E" | "D") ["+" | "-"] digit {digit}.
  64. hexDigit     = digit | "A" | "B" | "C" | "D" | "E" | "F".
  65. digit     = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9".
  66. Examples:
  67. 1991    INTEGER    1991
  68. 0DH     SHORTINT    13
  69. 12.3    REAL    12.3
  70. 4.567E8     REAL    456700000
  71. 0.57712566D-6     LONGREAL    0.00000057712566
  72. 3. Character constants are denoted by the ordinal number of the character in hexadecimal notation followed by the letter X.
  73. character  = digit {hexDigit} "X".
  74. 4. Strings are sequences of characters enclosed in single (') or double (") quote marks. The opening quote must be the same as the closing quote and must not occur within the string. The number of characters in a string is called its length. A string of length 1 can be used wherever a character constant is allowed and vice versa.
  75. string  = ' " ' {char} ' " ' | " ' " {char} " ' ".
  76. Examples:     "Oberon/L"     "Don't worry!"     "x"
  77. 5. Operators and delimiters are the special characters, character pairs, or reserved words listed below. The reserved words consist exclusively of capital letters and cannot be used as identifiers.
  78.     +    :=    ARRAY    IMPORT    RETURN
  79.     -    ^    BEGIN    IN    THEN
  80.     *    =    BY    IS    TO
  81.     /    #    CASE    LOOP    TYPE
  82.     ~    <    CONST    MOD    UNTIL
  83.     &    >    DIV    MODULE    VAR
  84.     .    <=    DO    NIL    WHILE
  85.     ,    >=    ELSE    OF    WITH
  86.     ;    ..    ELSIF    OR
  87.     |    :    END    POINTER
  88.     (    )    EXIT    PROCEDURE
  89.     [    ]    FOR    RECORD
  90.     {    }    IF    REPEAT
  91. 6. Comments may be inserted between any two symbols in a program. They are arbitrary character sequences opened by the bracket (* and closed by *). Comments may be nested. They do not affect the meaning of a program.
  92. 4. Declarations and scope rules
  93. Every identifier occurring in a program must be introduced by a declaration, unless it is a predeclared identifier. Declarations also specify certain permanent properties of an object, such as whether it is a constant, a type, a variable, or a procedure. The identifier is then used to refer to the associated object. 
  94.     The scope of an object x extends textually from the point of its declaration to the end of the block (module, procedure, or record) to which the declaration belongs and hence to which the object is local. It excludes the scopes of equally named objects which are declared in nested blocks. The scope rules are:
  95.     1.     No identifier may denote more than one object within a given scope (i.e. no identifier 
  96.         may be declared twice in a block);
  97.     2.     An object may only be referenced within its scope;
  98.     3.     A type T of the form POINTER TO T1 (see 6.4) can be declared at a point where T1 is still 
  99.         unknown. The  declaration of T1 must follow in the same block to which T is local;
  100.     4.    Identifiers denoting record fields (see 6.3) or type-bound procedures (see 10.2) are valid 
  101.         in record designators only.
  102. An identifier declared in a module block may be followed by an export mark (" * " or " - ") in its declaration to indicate that it is exported. An identifier x exported by a module M may be used in other modules, if they import M (see Ch.11). The identifier is then denoted as M.x in these modules and is called a qualified identifier. Identifiers marked with " - " in their declaration are read-only in importing modules.
  103. Qualident        = [ident "."] ident.
  104. IdentDef        = ident [" * " | " - "].
  105. The following identifiers are predeclared; their meaning is defined in the indicated sections:
  106.     ABS    (10.3)    LEN    (10.3)
  107.     ASH    (10.3)    LONG    (10.3)
  108.     BOOLEAN    (6.1)    LONGINT    (6.1)
  109.     CAP    (10.3)    LONGREAL    (6.1)
  110.     CHAR    (6.1)    MAX    (10.3)
  111.     CHR    (10.3)    MIN    (10.3)
  112.     COPY    (10.3)    NEW    (10.3)
  113.     DEC    (10.3)    ODD    (10.3)
  114.     ENTIER    (10.3)    ORD    (10.3)
  115.     EXCL    (10.3)    REAL    (6.1)
  116.     FALSE    (6.1)    SET    (6.1)
  117.     HALT    (10.3)    SHORT    (10.3)
  118.     INC    (10.3)    SHORTINT    (6.1)
  119.     INCL    (10.3)    SIZE    (10.3)
  120.     INTEGER    (6.1)    TRUE    (6.1)
  121. 5. Constant declarations
  122. A constant declaration associates an identifier with a constant value.
  123. ConstantDeclaration     = IdentDef "=" ConstExpression.
  124. ConstExpression     = Expression.
  125. A constant expression is an expression that can be evaluated by a mere textual scan without actually executing the program. Its operands are constants (Ch.8) or predeclared functions (Ch.10.3) that can be evaluated at compile time. Examples of constant declarations are:
  126. N = 100
  127. limit = 2*N - 1
  128. fullSet = {MIN(SET) .. MAX(SET)}
  129. 6. Type declarations
  130. A data type determines the set of values which variables of that type may assume, and the operators that are applicable. A type declaration associates an identifier with a type. In the case of structured types (arrays and records) it also defines the structure of variables of this type. A structured type cannot contain itself.
  131. TypeDeclaration     = IdentDef "=" Type.
  132. Type     = Qualident | ArrayType | RecordType | PointerType | ProcedureType.
  133. Examples:
  134. Table = ARRAY N OF REAL
  135. Tree = POINTER TO Node
  136. Node =  RECORD
  137.     key : INTEGER;
  138.     left, right: Tree
  139. CenterTree = POINTER TO CenterNode
  140. CenterNode = RECORD (Node)
  141.     width: INTEGER;
  142.     subnode: Tree
  143. Function = PROCEDURE (x: INTEGER): INTEGER
  144. 6.1 Basic types
  145. The basic types are denoted by predeclared identifiers. The associated operators are defined in 8.2 and the predeclared function procedures in 10.3. The values of the given basic types are the following:
  146. 1.    BOOLEAN    the truth values TRUE and FALSE
  147. 2.    CHAR    the characters of the Latin-1
  148. character set (0X .. 0FFX)
  149. 3.    SHORTINT    the integers between MIN(SHORTINT) and MAX(SHORTINT)
  150. 4.    INTEGER    the integers between MIN(INTEGER) and MAX(INTEGER)
  151. 5.    LONGINT    the integers between MIN(LONGINT) and MAX(LONGINT)
  152. 6.    REAL    the real numbers between MIN(REAL) and MAX(REAL)
  153. 7.    LONGREAL    the real numbers between MIN(LONGREAL) and MAX(LONGREAL)
  154. 8.    SET    the sets of integers between 0 and MAX(SET)
  155. Types 3 to 5 are integer types, types 6 and 7 are real types, and together they are called numeric types. They form a hierarchy; the larger type includes (the values of) the smaller type:
  156.     LONGREAL  >=  REAL  >=  LONGINT  >=  INTEGER  >=  SHORTINT
  157. 6.2 Array types
  158. An array is a structure consisting of a number of elements which are all of the same type, called the element type. The number of elements of an array is called its length. The elements of the array are designated by indices, which are integers between 0 and the length minus 1.
  159. ArrayType     = ARRAY [Length {"," Length}] OF Type.
  160. Length         = ConstExpression.
  161. A type of the form
  162.     ARRAY L0, L1, ..., Ln OF T
  163. is understood as an abbreviation of
  164.     ARRAY L0 OF
  165.         ARRAY L1 OF
  166.         ...
  167.             ARRAY Ln OF T
  168. Arrays declared without length are called open arrays. They are restricted to pointer base types (see 6.4), element types of open array types, and formal parameter types (see 10.1). Examples:
  169.     ARRAY 10, N OF INTEGER
  170.     ARRAY OF CHAR
  171. 6.3 Record types
  172. A record type is a structure consisting of a fixed number of elements, called fields, with possibly different types. The record type declaration specifies the name and type of each field. The scope of the field identifiers extends from the point of their declaration to the end of the record type, but they are also visible within designators referring to elements of record variables (see 8.1). If a record type is exported, field identifiers that are to be visible outside the declaring module must be marked. They are called public fields; unmarked elements are called private fields.
  173. RecordType     = RECORD ["("BaseType")"] FieldList {";" FieldList} END.
  174. BaseType         = Qualident.
  175. FieldList         = [IdentList ":" Type ].
  176. Record types are extensible, i.e. a record type can be declared as an extension of another record type. In the example
  177.     T0 = RECORD x: INTEGER END
  178.     T1 = RECORD (T0) y: REAL END
  179. T1 is a (direct) extension of T0 and T0 is the (direct) base type of T1 (see App. A). An extended type T1 consists of the fields of its base type and of the fields which are declared in T1. All identifiers declared in the extended record must be different from the identifiers declared in its base type record(s).
  180. Examples of record type declarations:
  181. RECORD
  182.     day, month, year: INTEGER
  183. RECORD
  184.     name, firstname: ARRAY 32 OF CHAR;
  185.     age: INTEGER;
  186.     salary: REAL
  187. 6.4 Pointer types
  188. Variables of a pointer type P assume as values pointers to variables of some type T. T is called the pointer base type of P and must be a record or array type. Pointer types adopt the extension relation of their pointer base types: if a type T1 is an extension of T, and P1 is of type POINTER TO T1, then P1 is also an extension of P.
  189.     PointerType = POINTER TO Type.
  190. If p is a variable of type P = POINTER TO T, a call of the predeclared procedure NEW(p) (see 10.3) allocates a variable of type T in free storage. If T is a record type or an array type with fixed length, the allocation has to be done with NEW(p); if T is an n-dimensional open array type the allocation has to be done with NEW(p, e0, ..., en-1) where T is allocated with lengths given by the expressions e0, ..., en-1. In either case a pointer to the allocated variable is assigned to p. p is of type P. The referenced  variable p^ (pronounced as p-referenced) is of type T. Any pointer variable may assume the value NIL, which points to no variable at all.
  191. 6.5 Procedure types
  192. Variables of a procedure type T have a procedure (or NIL) as value. If a procedure P is assigned to a variable of type T, the formal parameter lists (see Ch. 10.1) of P and T must match (see App. A). P must not be a predeclared or type-bound procedure nor may it be local to another procedure.
  193.     ProcedureType = PROCEDURE [FormalParameters].
  194. 7. Variable declarations
  195. Variable declarations introduce variables by defining an identifier and a data type for them.
  196.     VariableDeclaration = IdentList ":" Type.
  197. Record and pointer variables have both a static type (the type with which they are declared - simply called their type) and a dynamic type (the type of their value at run time). For pointers and variable parameters of record type the dynamic type may be an extension of their static type. The static type determines which fields of a record are accessible. The dynamic type is used to call type-bound procedures (see 10.2).
  198. Examples of variable declarations (refer to examples in Ch. 6):
  199. i, j, k: INTEGER
  200. x, y: REAL
  201. p, q: BOOLEAN
  202. s: SET
  203. F: Function
  204. a: ARRAY 100 OF REAL
  205. w: ARRAY 16 OF
  206.     RECORD
  207.         name: ARRAY 32 OF CHAR;
  208.         count: INTEGER
  209. t, c: Tree
  210. 8. Expressions
  211. Expressions are constructs denoting rules of computation whereby constants and current values of variables are combined to compute other values by the application of operators and function procedures. Expressions consist of operands and operators. Parentheses may be used to express specific associations of operators and operands.
  212. 8.1 Operands
  213. With the exception of set constructors and literal constants (numbers, character constants, or strings), operands are denoted by designators. A designator consists of an identifier referring to a constant, variable, or procedure. This identifier may possibly be qualified by a module identifier (see Ch. 4 and 11) and may be followed by selectors if the designated object is an element of a structure.
  214. Designator     = Qualident {"." ident | "[" ExpressionList "]" | "^" | "(" Qualident ")"}.
  215. ExpressionList     = Expression {"," Expression}.
  216. If a designates an array, then a[e] denotes that element of a whose index is the current value of the expression e. The type of e must be an integer type. A designator of the form a[e0, e1, ..., en] stands for a[e0][e1]...[en]. If r designates a record, then r.f denotes the field f of r or the procedure f bound to the dynamic type of r (Ch. 10.2). If p designates a pointer, p^ denotes the variable which is referenced by p. The designators p^.f and p^[e] may be abbreviated as p.f and p[e], i.e. record and array selectors imply dereferencing. If a or r are read-only, then also a[e] and r.f are read-only. 
  217.     A type guard v(T) asserts that the dynamic type of v is T (or an extension of T), i.e. program execution is aborted, if the dynamic type of v is not T (or an extension of T). Within the designator, v is then regarded as having the static type T. The guard is applicable, if
  218.     1.  v is a variable parameter of record type or v is a pointer, and if
  219.     2.  T is an extension of the static type of v
  220. If the designated object is a constant or a variable, then the designator refers to its current value. If it is a procedure, the designator refers to that procedure unless it is followed by a (possibly empty) parameter list in which case it implies an activation of that procedure and stands for the value resulting from its execution. The actual parameters must correspond to the formal parameters as in proper procedure calls (see 10.1).
  221. Examples of designators (refer to examples in Ch.7):
  222. i    (INTEGER)
  223. a[i]    (REAL)
  224. w[3].name[i]    (CHAR)
  225. t.left.right    (Tree)
  226. t(CenterTree).subnode    (Tree)
  227. 8.2 Operators
  228. Four classes of operators with different precedences (binding strengths) are syntactically distinguished in expressions. The operator ~ has the highest precedence, followed by multiplication operators, addition operators, and relations. Operators of the same precedence associate from left to right. For example, x-y-z stands for (x-y)-z.
  229. Expression     = SimpleExpression [Relation SimpleExpression].
  230. SimpleExpression    = ["+" | "-"] Term {AddOperator Term}.
  231. Term     = Factor {MulOperator Factor}.
  232. Factor     = Designator [ActualParameters] | 
  233.         number | character | string | NIL | Set | "(" Expression ")" | "~" Factor.
  234. Set     = "{" [Element {"," Element}] "}".
  235. Element     = Expression [".." Expression].
  236. ActualParameters     = "(" [ExpressionList] ")".
  237. Relation     = "=" | "#" | "<" | "<=" | ">" | ">=" | IN | IS.
  238. AddOperator     = "+" | "-" | OR.
  239. MulOperator     = "*" | "/" | DIV | MOD | "&".
  240. The available operators are listed in the following tables. Some operators are applicable to operands of various types, denoting different operations. In these cases, the actual operation is identified by the type of the operands. The operands must be expression compatible with respect to the operator (see App. A).
  241. 8.2.1 Logical operators
  242. OR    logical disjunction     p OR q      "if p then TRUE, else q"
  243. &    logical conjunction     p & q      "if p then q, else FALSE"
  244. ~    negation     ~ p      "not p"
  245. These operators apply to BOOLEAN operands and yield a BOOLEAN result.
  246. 8.2.2 Arithmetic operators
  247. +    sum
  248. -    difference
  249. *    product
  250. /    real quotient
  251. DIV    integer quotient
  252. MOD    modulus
  253. The operators +, -, *, and / apply to operands of numeric types. The type of the result is the type of that operand which includes the type of the other operand, except for division (/), where the result is the smallest real type which includes both operand types. When used as monadic operators, - denotes sign inversion and + denotes the identity operation. The operators DIV and MOD apply to integer operands only. They are related by the following formulas:
  254. x = (x DIV y) * y + (x MOD y)
  255. 0 <= (x MOD y) < y  or
  256. Note:
  257. ENTIER(x
  258. Examples:
  259.  x     y    x DIV y    x MOD y
  260.  5     3       1              2
  261. -5     3      -2              1
  262.  5    -3      -2             -1
  263. -5    -3       1             -2
  264. 8.2.3 Set Operators
  265. +    union
  266. -    difference (x - y = x * (-y))
  267. *    intersection
  268. /    symmetric set difference (x / y = (x-y) + (y-x))
  269. Set operators apply to operands of type SET and yield a result of type SET. The monadic minus sign denotes the complement of x, i.e. -x denotes the set of integers between 0 and MAX(SET) which are not elements of x. Set operators are not associative ((a+b)-c # a+(b-c)).
  270. A set constructor defines the value of a set by listing its elements between curly brackets. The elements must be integers in the range 0..MAX(SET). A range a..b denotes all integers i
  271. with i
  272. 8.2.4 Relations
  273. =    equal
  274. #    unequal
  275. <    less
  276. <=    less or equal
  277. >    greater
  278. >=    greater or equal
  279. IN    set membership
  280. IS    type test
  281. Relations yield a BOOLEAN result. The relations =, #, <, <=, >, and >= apply to the numeric types, CHAR, strings, and character arrays containing 0X as a terminator. The relations = and # also apply to BOOLEAN and SET, as well as to pointer and procedure types (including the value NIL). x IN s stands for "x is an element of s". x must be of an integer type, and s of type SET. v IS T stands for "the dynamic type of v is T (or an extension of T)" and is called a type test. It is applicable if
  282. 1.  v is a variable parameter of record type or v is a pointer, and if
  283. 2.  T is an extension of the static type of v
  284. Examples of expressions (refer to examples in Ch.7):
  285. 1991    INTEGER
  286. i DIV 3    INTEGER
  287. ~p OR q    BOOLEAN
  288. (i+j) * (i-j)    INTEGER
  289. s - {8, 9, 13}    SET
  290. i + x    REAL
  291. a[i+j] * a[i-j]    REAL
  292. (0<=i) & (i<100)    BOOLEAN
  293. t.key = 0    BOOLEAN
  294. k IN {i..j-1}    BOOLEAN
  295. w[i].name <= "John"    BOOLEAN
  296. t IS CenterTree    BOOLEAN
  297. 9. Statements
  298. Statements denote actions. There are elementary and structured statements. Elementary statements are not composed of any parts that are themselves statements. They are the assignment, the procedure call, the return, and the exit statement. Structured statements are composed of parts that are themselves statements. They are used to express sequencing and conditional, selective, and repetitive execution. A statement may also be empty, in which case it denotes no action. The empty statement is included in order to relax punctuation rules in statement sequences.
  299.     Statement =    [ Assignment | ProcedureCall | IfStatement | CaseStatement |
  300.         WhileStatement | RepeatStatement |
  301.         ForStatement | LoopStatement | WithStatement | EXIT | RETURN [Expression] ].
  302. 9.1 Assignments
  303. Assignments replace the current value of a variable by a new value specified by an expression. The expression must be assignment compatible with the variable (see App. A). The assignment operator is written as ":=" and pronounced as becomes.
  304.     Assignment = Designator ":=" Expression.
  305. If an expression e of type Te is assigned to a variable v of type Tv, the following happens:
  306.     1.     if Tv and Te are record types, only those fields of Te are assigned which also belong to
  307.         Tv (projection); the dynamic type of v  must be the same as the static type of v and  is
  308.         not changed by the assignment;
  309.     2.    if Tv and Te are pointer types, the dynamic type of v becomes the dynamic type of e;
  310.     3.    if Tv is ARRAY n OF CHAR and e is a string of length m<n, v[i] becomes ei for i = 0..m-1
  311.         and v[m] becomes 0X.
  312. Examples of assignments (refer to examples in Ch.7):
  313. i := 0
  314. p := i = j
  315. x := i + 1
  316. k := log2(i+j)
  317. F := log2        (* see 10.1 *)
  318. s := {2, 3, 5, 7, 11, 13}
  319. a[i] := (x+y) * (x-y)
  320. t.key := i
  321. w[i+1].name := "John"
  322. t := c
  323. 9.2 Procedure calls
  324. A procedure call activates a procedure. It may contain a list of actual parameters which replace the corresponding formal parameters defined in the procedure declaration (see Ch. 10). The correspondence is established by the positions of the parameters in the actual and formal parameter lists. There are two kinds of parameters: variable and value parameters.
  325.     If a formal parameter is a variable parameter, the corresponding actual parameter must be a designator denoting a variable. If it denotes an element of a structured variable, the component selectors are evaluated when the formal/actual parameter substitution takes place, i.e. before the execution of the procedure. If a formal parameter is a value parameter, the corresponding actual parameter must be an expression. This expression is evaluated before the procedure activation, and the resulting value is assigned to the formal parameter (see also 10.1).
  326.     ProcedureCall = Designator [ActualParameters].
  327. Examples:
  328. WriteInt(i*2+1)    (* see 10.1 *)
  329. INC(w[k].count)
  330. t.Insert("John")    (* see 11 *)
  331. 9.3 Statement sequences
  332. Statement sequences denote the sequence of actions specified by the component statements which are separated by semicolons.
  333.     StatementSequence = Statement {";" Statement}.
  334. 9.4 If statements
  335.     IfStatement = 
  336.         IF Expression THEN StatementSequence
  337.         {ELSIF Expression THEN StatementSequence}
  338.         [ELSE StatementSequence]
  339.         END.
  340. If statements specify the conditional execution of guarded statement sequences. The Boolean expression preceding a statement sequence is called its guard. The guards are evaluated in sequence of occurrence, until one evaluates to TRUE, whereafter its associated statement sequence is executed. If no guard is satisfied, the statement sequence following the symbol ELSE is executed, if there is one.
  341. Example:
  342. IF (ch >= "A") & (ch <= "Z") THEN ReadIdentifier
  343. ELSIF (ch >= "0") & (ch <= "9") THEN ReadNumber
  344. ELSIF (ch = " ' ") OR (ch = ' " ') THEN ReadString
  345. ELSE SpecialCharacter
  346. 9.5 Case statements
  347. Case statements specify the selection and execution of a statement sequence according to the value of an expression. First the case expression is evaluated, then that statement sequence is executed whose case label list contains the obtained value. The case expression must either be of an integer type that includes the types of all case labels, or both the case expression and the case labels must be of type CHAR. Case labels are constants, and no value must occur more than once. If the value of the expression does not occur as a label of any case, the statement sequence following the symbol ELSE is selected, if there is one, otherwise the program is aborted.
  348. CaseStatement     = CASE Expression OF Case {"|" Case} [ELSE StatementSequence] END.
  349. Case     = [CaseLabelList ":" StatementSequence].
  350. CaseLabelList     = CaseLabels {"," CaseLabels}.
  351. CaseLabels     = ConstExpression [".." ConstExpression].
  352. Example:
  353. CASE ch OF
  354.     "A" .. "Z": ReadIdentifier 
  355. |    "0" .. "9": ReadNumber 
  356. |    " ' ", ' " ': ReadString
  357. ELSE SpecialCharacter
  358. 9.6 While statements
  359. While statements specify the repeated execution of a statement sequence while the Boolean expression (its guard) yields TRUE. The guard is checked before every execution of the statement sequence.
  360.     WhileStatement = WHILE Expression DO StatementSequence END.
  361. Examples:
  362. WHILE i > 0 DO i := i DIV 2; k := k + 1 END
  363. WHILE (t # NIL) & (t.key # i) DO t := t.left END
  364. 9.7 Repeat statements
  365. A repeat statement specifies the repeated execution of a statement sequence until a condition specified by a Boolean expression is satisfied. The statement sequence is executed at least once.
  366.     RepeatStatement = REPEAT StatementSequence UNTIL Expression.
  367. 9.8 For statements
  368. A for statement specifies the repeated execution of a statement sequence while a progression of values is assigned to an integer variable called the control variable of the for statement.
  369.     ForStatement =
  370.         FOR ident ":=" Expression TO Expression [BY ConstExpression]
  371.         DO StatementSequence END.
  372. The statement
  373.     FOR v := beg TO end BY step DO statements END
  374. is equivalent to
  375. temp := end; v := beg;
  376. IF step > 0 THEN
  377.     WHILE v <= temp DO statements; v := v + step END
  378.     WHILE v >= temp DO statements; v := v + step END
  379. temp has the same type as v. step must be a nonzero constant expression. If step is not specified, it is assumed to be 1.
  380. Examples:
  381. FOR i := 0 TO 79 DO k := k + a[i] END
  382. FOR i := 79 TO 1 BY -1 DO a[i] := a[i-1] END
  383. 9.9 Loop statements
  384. A loop statement specifies the repeated execution of a statement sequence. It is terminated upon execution of an exit statement within that sequence (see 9.10).
  385.     LoopStatement = LOOP StatementSequence END.
  386. Example:
  387.     ReadInt(i);
  388.     IF i < 0 THEN EXIT END;
  389.     WriteInt(i)
  390. Loop statements are useful to express repetitions with several exit points or cases where the exit condition is in the middle of the repeated statement sequence.
  391. 9.10 Return and exit statements
  392. A return statement indicates the termination of a procedure. It is denoted by the symbol RETURN, followed by an expression if the procedure is a function procedure. The type of the expression must be assignment compatible (see App. A) with the result type specified in the procedure heading (see Ch.10).
  393.     Function procedures require the presence of a return statement indicating the result value. In proper procedures, a return statement is implied by the end of the procedure body. Any explicit return statement therefore appears as an additional (probably exceptional) termination point.
  394.     An exit statement is denoted by the symbol EXIT. It specifies termination of the enclosing loop statement and continuation with the statement following that loop statement. Exit statements are contextually, although not syntactically associated with the loop statement which contains them.
  395. 9.11 With statements
  396. With statements execute a statement sequence depending on the result of a type test and apply a type guard to every occurrence of the tested variable within this statement sequence.
  397. WithStatement     = WITH Guard DO StatementSequence {"|" Guard DO StatementSequence}
  398.         [ELSE StatementSequence] END.
  399. Guard    = Qualident ":" Qualident.
  400. If v is a variable parameter of record type or a pointer variable, and if it is of a static type T0, the statement
  401.     WITH v: T1 DO S1 | v: T2 DO S2 ELSE S3 END
  402. has the following meaning: if the dynamic type of v is T1, then the statement sequence S1 is executed where v is regarded as if it had the static type T1; else if the dynamic type of v is T2, then S2 is executed where v is regarded as if it had the static type T2; else S3 is executed. T1 and T2 must be extensions of T0. If no type test is satisfied and if an else clause is missing the program is aborted.
  403. Example:
  404. WITH t: CenterTree DO i := t.width; c := t.subnode END
  405. 10. Procedure declarations
  406. A procedure declaration consists of a procedure heading and a procedure body. The heading specifies the procedure identifier and the formal parameters. For type-bound procedures it also specifies the receiver parameter. The body contains declarations and statements. The procedure identifier is repeated at the end of the procedure declaration.
  407.     There are two kinds of procedures: proper procedures and function procedures. The latter are activated by a function designator as a constituent of an expression and yield a result that is an operand of the expression. Proper procedures are activated by a procedure call. A procedure is a function procedure if its formal parameters specify a result type. The body of a function procedure must contain a return statement which defines its result.
  408.     All constants, variables, types, and procedures declared within a procedure body are local to the procedure. Since procedures may be declared as local objects too, procedure declarations may be nested. The call of a procedure within its declaration implies recursive activation.
  409.     Objects declared in the environment of the procedure are also visible in those parts of the procedure in which they are not concealed by a locally declared object with the same name.
  410. ProcedureDeclaration    = ProcedureHeading ";" ProcedureBody ident.
  411. ProcedureHeading     = PROCEDURE [Receiver] IdentDef [FormalParameters].
  412. ProcedureBody     = DeclarationSequence [BEGIN StatementSequence] END.
  413. DeclarationSequence     = {CONST {ConstantDeclaration ";"} | TYPE {TypeDeclaration ";"} |
  414.         VAR {VariableDeclaration ";"} }
  415.         {ProcedureDeclaration ";" | ForwardDeclaration ";"}.
  416. ForwardDeclaration     = PROCEDURE " ^ " [Receiver] IdentDef [FormalParameters].
  417. If a procedure declaration specifies a receiver parameter, the procedure is considered to be bound to a type (see 10.2). A forward declaration serves to allow forward references to a procedure whose actual declaration appears later in the text. The formal parameter lists of the forward declaration and the actual declaration must match (see App. A).
  418. 10.1 Formal parameters
  419. Formal parameters are identifiers declared in the formal parameter list of a procedure. They correspond to actual parameters specified in the procedure call. The correspondence between formal and actual parameters is established when the procedure is called. There are two kinds of parameters, value and variable parameters, indicated in the formal parameter list by the absence or presence of the keyword VAR. Value parameters are local variables to which the value of the corresponding actual parameter is assigned as an initial value. Variable parameters correspond to actual parameters that are variables, and they stand for these variables. The scope of a formal parameter extends from its declaration to the end of the procedure block in which it is declared. A function procedure without parameters must have an empty parameter list. It must be called by a function designator whose actual parameter list is empty too. The result type of a procedure can be neither a record nor an array.
  420. FormalParameters    = "(" [FPSection {";" FPSection}] ")" [":" Qualident].
  421. FPSection     = [VAR] ident {"," ident} ":" Type.
  422. Let Tf be the type of a formal parameter f (not an open array) and Ta the type of the corresponding actual parameter a. For variable parameters, Ta must be the same as Tf, or Tf must be a record type and Ta an extension of Tf. For value parameters, a must be assignment compatible with f (see App. A).
  423.     If Tf is an open array , then a must be array compatible with f (see App. A). The lengths of f are taken from a.
  424. Examples of procedure declarations:
  425. PROCEDURE ReadInt (VAR x: INTEGER);
  426.     VAR i: INTEGER; ch: CHAR;
  427. BEGIN
  428.     i := 0; Read(ch);
  429.     WHILE ("0" <= ch) & (ch <= "9") DO
  430.         i := 10*i + (ORD(ch)-ORD("0")); Read(ch)
  431.     END;
  432.     x := i
  433. END ReadInt
  434. PROCEDURE WriteInt (x: INTEGER);    (*0 <= x <100000*)
  435.     VAR i: INTEGER; buf: ARRAY 5 OF INTEGER;
  436. BEGIN
  437.     i := 0;
  438.     REPEAT buf[i] := x MOD 10; x := x DIV 10; INC(i) UNTIL x = 0;
  439.     REPEAT DEC(i); Write(CHR(buf[i] + ORD("0"))) UNTIL i = 0
  440. END WriteInt
  441. PROCEDURE WriteString (s: ARRAY OF CHAR);
  442.     VAR i: INTEGER;
  443. BEGIN
  444.     i := 0; WHILE (i < LEN(s)) & (s[i] # 0X) DO Write(s[i]); INC(i) END
  445. END WriteString;
  446. PROCEDURE log2 (x: INTEGER): INTEGER;
  447.     VAR y: INTEGER;    (*assume x>0*)
  448. BEGIN
  449.     y := 0; WHILE x > 1 DO x := x DIV 2; INC(y) END;
  450.     RETURN y
  451. END log2
  452. 10.2 Type-bound procedures
  453. Globally declared procedures may be associated with a record type declared in the same module. The procedures are said to be bound to the record type. The binding is expressed by the type of the receiver in the heading of a procedure declaration.  The receiver may be either a variable parameter of record type T or a value parameter of type POINTER TO T (where T is a record type). The procedure is bound to the type T and is considered local to it.
  454. ProcedureHeading    = PROCEDURE [Receiver] IdentDef [FormalParameters].
  455. Receiver     = "(" [VAR] ident ":" ident ")".
  456. If a procedure P is bound to a type T0, it is implicitly also bound to any type T1 which is an extension of T0. However, a procedure P' (with the same name as P) may be explicitly bound to T1 in which case it overrides the binding of P. P' is considered a redefinition of P for T1. The formal parameters of P and P' must match (see App. A),
  457. except
  458. function
  459. procedure returning
  460. pointer
  461. type.
  462. latter
  463. case,
  464. function
  465. result
  466. extension of
  467. function
  468. result
  469. (covariance). If P and T1 are exported (see Chapter 4) P' must be exported too.
  470.     If v is a designator and P is a type-bound procedure, then v.P denotes that procedure P which is bound to the dynamic type of v. Note, that this may be a different procedure than the one bound to the static type of v. v is passed to P's receiver according to the parameter passing rules specified in Chapter 10.1.
  471.     If r is a receiver parameter declared with type T, r.P^ denotes the (redefined) procedure P bound to the base type of T.
  472. In a forward declaration of a type-bound procedure the receiver parameter must be of the same type as in the actual procedure declaration. The formal parameter lists of both declarations must match (App. A).
  473. Examples:
  474. PROCEDURE (t: Tree) Insert (node: Tree);
  475.     VAR p, father: Tree;
  476. BEGIN p := t;
  477.     REPEAT father := p;
  478.         IF node.key = p.key THEN RETURN END;
  479.         IF node.key < p.key THEN p := p.left ELSE p := p.right END
  480.     UNTIL p = NIL;
  481.     IF node.key < father.key THEN father.left := node ELSE father.right := node END;
  482.     node.left := NIL; node.right := NIL
  483. END Insert;
  484. PROCEDURE (t: CenterTree) Insert (node: Tree);  (*redefinition*)
  485. BEGIN
  486.     WriteInt(node(CenterTree).width);
  487.     t.Insert^ (node)  (* calls the Insert procedure bound to Tree *)
  488. END Insert;
  489. 10.3 Predeclared procedures
  490. The following table lists the predeclared procedures. Some are generic procedures, i.e. they apply to several types of operands. v stands for a variable, x and n for expressions, and T for a type.
  491. Function procedures
  492. Name    Argument type    Result type    Function
  493. ABS(x)    numeric type    type of x    absolute value
  494. ASH(x, n)    x, n: integer type    LONGINT    arithmetic shift (x * 2n)
  495. CAP(x)    CHAR    CHAR    x is letter: corresponding capital letter
  496. CHR(x)    integer type    CHAR    character with ordinal number x
  497. ENTIER(x)    real type    LONGINT    largest integer not greater than x
  498. LEN(v, n)    v: array; n: integer constant    LONGINT    length of v in dimension n
  499.             (first dimension = 0)
  500. LEN(v)    v: array    LONGINT    equivalent to LEN(v, 0)
  501. LONG(x)    SHORTINT    INTEGER    identity
  502.     INTEGER    LONGINT
  503.     REAL    LONGREAL
  504. MAX(T)    T = basic type    T    maximum value of type T
  505.     T = SET    INTEGER    maximum element of a set
  506. MIN(T)    T = basic type    T    minimum value of type T
  507.     T = SET    INTEGER    0
  508. ODD(x)    integer type    BOOLEAN    x MOD 2 = 1
  509. ORD(x)    CHAR    INTEGER    ordinal number of x
  510. SHORT(x)    LONGINT    INTEGER    identity
  511.     INTEGER    SHORTINT    identity
  512.     LONGREAL    REAL    identity (truncation possible)
  513. SIZE(T)    any type    integer type    number of bytes required by T
  514. Proper procedures
  515. Name    Argument types    Function
  516. ASSERT(x)    x: Boolean expression    terminate program execution if not x
  517. ASSERT(x, n)    x: Boolean expression; n: integer constant
  518.         terminate program execution if not x
  519. COPY(x, v)    x: character array, string; v: character array    v := x
  520. DEC(v)    integer type    v := v - 1
  521. DEC(v, n)    v, n: integer type    v := v - n
  522. EXCL(v, x)    v: SET; x: integer type    v := v - {x}
  523. HALT(n)    integer constant    terminate program execution
  524. INC(v)    integer type    v := v + 1
  525. INC(v, n)    v, n: integer type    v := v + n
  526. INCL(v, x)    v: SET; x: integer type    v := v + {x}
  527. NEW(v)    pointer to record or fixed array    allocate v ^
  528. NEW(v, x0, ..., xn    v: pointer to open array; xi: integer type
  529.         allocate v ^ with lengths x0.. xn
  530. COPY allows the assignment of a string or a character array containing a terminating 0X to another character array. If necessary, the assigned value is truncated to the target length minus one. The target will always contain 0X as a terminator. In ASSERT(x, n) and HALT(n), the interpretation of n is left to the underlying system implementation.
  531. 11. Modules
  532. A module is a collection of declarations of constants, types, variables, and procedures, together with a sequence of statements for the purpose of assigning initial values to the variables. A module constitutes a text that is compilable as a unit.
  533. Module    = MODULE ident ";" [ImportList] DeclarationSequence [BEGIN StatementSequence] END ident ".".
  534. ImportList    = IMPORT Import {"," Import} ";".
  535. Import     = [ident ":="] ident.
  536. The import list specifies the names of the imported modules. If a module A is imported by a module M and A exports an identifier x, then x is referred to as A.x within M. If A is imported as B := A, the object x must be referenced as B.x. This allows short alias names in qualified identifiers. A module must not import itself. Identifiers that are to be exported (i.e. that are to be visible in client modules) must be marked by an export mark in their declaration (see Chapter 4).
  537.     The statement sequence following the symbol BEGIN is executed when the module is added to a system (loaded), which is done after the imported modules have been loaded. It follows that cyclic import of modules is illegal. Individual (parameterless and exported) procedures can be activated from the system, and these procedures serve as commands (see Appendix D1).
  538. MODULE Trees;     (* exports: Tree, Node, Insert, Search, Write, Init *)
  539.     IMPORT Texts, Oberon;    (* exports read-only: Node.name *)
  540.     TYPE
  541.         Tree* = POINTER TO Node;
  542.         Node* = RECORD
  543.             name-: POINTER TO ARRAY OF CHAR;
  544.             left, right: Tree
  545.         END;
  546.     VAR w: Texts.Writer;
  547.     PROCEDURE (t: Tree) Insert* (name: ARRAY OF CHAR);
  548.         VAR p, father: Tree;
  549.     BEGIN p := t;
  550.         REPEAT father := p;
  551.             IF name = p.name^ THEN RETURN END;
  552.             IF name < p.name^ THEN p := p.left ELSE p := p.right END
  553.         UNTIL p = NIL;
  554.         NEW(p); p.left := NIL; p.right := NIL;
  555.         NEW(p.name, LEN(name)+1); COPY(name, p.name^);
  556.         IF name < father.name^ THEN father.left := p ELSE father.right := p END
  557.     END Insert;
  558.     PROCEDURE (t: Tree) Search* (name: ARRAY OF CHAR): Tree;
  559.         VAR p: Tree;
  560.     BEGIN p := t;
  561.         WHILE (p # NIL) & (name # p.name^) DO
  562.             IF name < p.name^ THEN p := p.left ELSE p := p.right END
  563.         END;
  564.         RETURN p
  565.     END Search;
  566.     PROCEDURE (t: Tree) Write*;
  567.     BEGIN
  568.         IF t.left # NIL THEN t.left.Write END;
  569.         Texts.WriteString(w, t.name^); Texts.WriteLn(w); Texts.Append(Oberon.Log, w.buf);
  570.         IF t.right # NIL THEN t.right.Write END
  571.     END Write;
  572.     PROCEDURE Init* (t: Tree);
  573.     BEGIN NEW(t.name, 1); t.name[0] := 0X; t.left := NIL; t.right := NIL
  574.     END Init;
  575. BEGIN Texts.OpenWriter(w)
  576. END Trees.
  577. Appendix A: Definition of terms
  578. Integer types    SHORTINT, INTEGER, LONGINT
  579. Real types    REAL, LONGREAL
  580. Numeric types    integer types, real types
  581. Same types
  582. Two variables a and b with types Ta and Tb are of the same type if
  583. 1.  Ta and Tb are both denoted by the same type identifier, or
  584. 2.  Ta is declared to equal Tb in a type declaration of the form Ta = Tb, or
  585. 3.  a and b appear in the same identifier list in a variable, record field, or formal parameter
  586.     declaration and are not open arrays.
  587. Equal types
  588. Two types Ta and Tb are equal if
  589. 1.  Ta and Tb are the same type,  or
  590. 2.  Ta and Tb are open array types with equal element types, or
  591. 3.  Ta and Tb are procedure types whose formal parameter lists match.
  592. Type inclusion
  593. Numeric types include (the values of) smaller numeric types according to the following hierarchy:
  594.     LONGREAL >= REAL >= LONGINT >= INTEGER >= SHORTINT
  595. Type extension (base type)
  596. Given a type declaration Tb = RECORD (Ta) ... END, Tb is a direct extension of Ta, and Ta is a direct base type of Tb. A type Tb is an extension of a type Ta (Ta is a base type of Tb) if
  597. 1.  Ta and Tb are the same types, or
  598. 2.  Tb is a direct extension of an extension of Ta
  599.     If Pa = POINTER TO Ta and Pb = POINTER TO Tb, Pb is an extension of Pa
  600.      (Pa is a base type of Pb) if Tb is an extension of Ta.
  601. Assignment compatible
  602. An expression e of type Te is assignment compatible with a variable v of type Tv if one of the following conditions hold:
  603. 1.  Te and Tv are the same type;
  604. 2.  Te and Tv are numeric types and Tv includes Te;
  605. 3.  Te and Tv are record types and Te is an extension of Tv and the dynamic type of v is Tv ;
  606. 4.  Te and Tv are pointer types and Te is an extension of Tv;
  607. 5.  Tv is a pointer or a procedure type and e is NIL;
  608. 6.  Tv is ARRAY n OF CHAR, e is a string constant with m characters, and m < n;
  609. 7.  Tv is a procedure type and e is the name of a procedure whose formal parameters match
  610.     those of Tv.
  611. Array compatible
  612. An actual parameter a of type Ta is array compatible with a formal parameter f of type Tf if
  613. 1.  Tf and Ta are the same type, or
  614. 2.  Tf is an open array, Ta is any array, and their element types are array compatible, or
  615. 3.  Tf is ARRAY OF CHAR and a is a string.
  616. Expression compatible
  617. For a given operator, the types of its operands are expression compatible if they conform to the following table (which shows also the result type of the expression). Character arrays that are to be compared must contain 0X as a terminator. Type T1 must be an extension of type T0:
  618. operator     first operand    second operand     result type
  619. + - *    numeric    numeric    smallest numeric type
  620.             including both operands
  621. /    numeric    numeric    smallest real type
  622.             including both operands
  623. + - * /    SET    SET    SET
  624. DIV MOD    integer    integer    smallest integer type
  625.             including both operands
  626. OR & ~    BOOLEAN    BOOLEAN    BOOLEAN
  627. = # < <= > >=    numeric    numeric    BOOLEAN
  628.     CHAR    CHAR    BOOLEAN
  629.     character array, string    character array, string    BOOLEAN
  630. = #    BOOLEAN    BOOLEAN    BOOLEAN
  631.     SET    SET    BOOLEAN
  632.     NIL, pointer type T0 or T1    NIL, pointer type T0 or T1    BOOLEAN
  633.     procedure type T, NIL    procedure type T, NIL    BOOLEAN
  634. IN    integer    SET    BOOLEAN
  635. IS    type T0    type T1    BOOLEAN
  636. Matching formal parameter lists
  637. Two formal parameter lists match if
  638. 1.  they have the same number of parameters, and
  639. 2.  they have either the same function result type or none, and
  640. 3.  parameters at corresponding positions have equal types, and
  641. 4.  parameters at corresponding positions are both either value or variable parameters.
  642. Appendix B: Syntax of Oberon/L
  643. Module     =    MODULE ident ";" [ImportList] DeclSeq  [BEGIN StatementSeq] END ident ".".
  644. ImportList     =    IMPORT [ident ":="] ident {"," [ident ":="] ident} ";".
  645. DeclSeq     =    { CONST {ConstDecl ";" } | TYPE {TypeDecl ";"} | VAR {VarDecl ";"}}
  646.             {ProcDecl ";" | ForwardDecl ";"}.
  647. ConstDecl    =    IdentDef "=" ConstExpr.
  648. TypeDecl    =    IdentDef "=" Type.
  649. VarDecl    =    IdentList ":" Type.
  650. ProcDecl     =    PROCEDURE [Receiver] IdentDef [FormalPars] ";" DeclSeq
  651.             [BEGIN StatementSeq] END ident.
  652. ForwardDecl    =    PROCEDURE "^" [Receiver] IdentDef [FormalPars].
  653. FormalPars     =    "(" [FPSection {";" FPSection}] ")" [":" Qualident].
  654. FPSection     =    [VAR] ident {"," ident} ":" Type.
  655. Receiver    =    "(" [VAR] ident ":" ident ")".
  656. Type     =    Qualident
  657.         |  ARRAY [ConstExpr {"," ConstExpr}] OF Type 
  658.         | RECORD ["("Qualident")"] FieldList {";" FieldList} END
  659.         | POINTER TO Type
  660.         | PROCEDURE [FormalPars].
  661. FieldList     =    [IdentList ":" Type].
  662. StatementSeq    =    Statement {";" Statement}.
  663. Statement     =    [ Designator ":=" Expr 
  664.         | Designator ["(" [ExprList] ")"] 
  665.         | IF Expr THEN StatementSeq {ELSIF Expr THEN StatementSeq}
  666.             [ELSE StatementSeq] END 
  667.         | CASE Expr OF Case {"|" Case} [ELSE StatementSeq] END 
  668.         | WHILE Expr DO StatementSeq END 
  669.         | REPEAT StatementSeq UNTIL Expr 
  670.         | FOR ident ":=" Expr TO Expr [BY ConstExpr] DO StatementSeq END 
  671.         | LOOP StatementSeq END
  672.         | WITH Guard DO StatementSeq {"|" Guard DO StatementSeq}
  673.             [ELSE StatementSeq] END
  674.         | EXIT 
  675.         | RETURN [Expr]
  676. Case     =    [CaseLabels {"," CaseLabels} ":" StatementSeq].
  677. CaseLabels     =    ConstExpr [".." ConstExpr].
  678. Guard    =    Qualident ":" Qualident.
  679. ConstExpr    =    Expr.
  680. Expr     =    SimpleExpr [Relation SimpleExpr].
  681. SimpleExpr    =    ["+" | "-"] Term {AddOp Term}.
  682. Term     =    Factor {MulOp Factor}.
  683. Factor     =    Designator
  684.             ["(" [ExprList] ")"] | number | character | string | NIL | Set | "(" Expr ")" |
  685.             " ~ " Factor.
  686. Set    =    "{" [Element {"," Element}] "}".
  687. Element     =    Expr [".." Expr].
  688. Relation     =    "=" | "#" | "<" | "<=" | ">" | ">=" | IN | IS.
  689. AddOp     =    "+" | "-" | OR.
  690. MulOp     =    " * " | "/" | DIV | MOD | "&".
  691. Designator     =    Qualident {"." ident | "[" ExprList "]" | " ^ " | "(" Qualident ")"}.
  692. ExprList     =    Expr {"," Expr}.
  693. IdentList     =    IdentDef {"," IdentDef}.
  694. Qualident     =    [ident "."] ident.
  695. IdentDef     =    ident [" * " | "-"].
  696. Appendix
  697. Domains
  698. Basic
  699. Types
  700. Type    Domain
  701. BOOLEAN    FALSE, TRUE
  702. CHAR    0X .. 0FFX
  703. SHORTINT    -128 .. 128
  704. INTEGER    -32768 .. 32767
  705. LONGINT    -2147483648 .. 2147483647
  706. REAL    32-bit IEEE format
  707. LONGREAL    64-bit IEEE format
  708. SET    set of 0 .. 31
  709. TextControllers.StdCtrlDesc
  710. TextControllers.ControllerDesc
  711. Containers.ControllerDesc
  712. Controllers.ControllerDesc
  713. Geneva
  714. Documents.ControllerDesc
  715.